package com.runen.infinitemovement.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.runen.infinitemovement.R;
import com.runen.infinitemovement.model.entity.RecommendActivitiesEntity;
import com.runen.infinitemovement.tool.GlideUtils;
import com.runen.infinitemovement.widget.RoundishImageView;
import com.runen.rxnetlibrary.utils.TimeUtil;

public class ColumnActivityAdapter extends BaseQuickAdapter<RecommendActivitiesEntity, BaseViewHolder> {
    private Context context;
    long now;
    long beginTime;
    long endTime;

    public ColumnActivityAdapter(Context context) {
        super(R.layout.item_column_activity);
        this.context = context;
    }

    @SuppressLint("NewApi")
    @Override
    protected void convert(@NonNull BaseViewHolder helper, RecommendActivitiesEntity item) {
        RoundishImageView riv_cover = helper.getView(R.id.riv_cover);
        TextView tv_enter_num = helper.getView(R.id.tv_enter_num);
        TextView tv_activity_type = helper.getView(R.id.tv_activity_type);
        TextView tv_jinxing = helper.getView(R.id.tv_jinxing);
        TextView tv_start_end_time = helper.getView(R.id.tv_start_end_time);
        GlideUtils.loadImage(context, item.cover, riv_cover);
        String enterNum = "%s 人参与";
        tv_enter_num.setText(String.format(enterNum, item.participationNumber));
        tv_jinxing.setText(item.state);

        tv_activity_type.setText(item.activeName);

        if (null != item.activeBegin && null != item.activeDeadline) {
            now = System.currentTimeMillis();
//            beginTime = TimeUtil.getDateTimeToLong(TimeUtil.dealDateFormat1(item.activeBegin));
//            endTime = TimeUtil.getDateTimeToLong(TimeUtil.dealDateFormat1(item.activeDeadline));
            String string = "%s-%s";
            tv_start_end_time.setText(String.format(string, TimeUtil.dealDateFormat2(item.activeBegin), TimeUtil.dealDateFormat2(item.activeDeadline)));
        }
    }
}
